package com.witdata.controller.student;

import com.witdata.common.domain.Result;
import com.witdata.common.domain.Status;
import com.witdata.mysql.base.service.UserLearningSessionService;
import com.witdata.mysql.domain.entity.UserLearningSession;
import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequiredArgsConstructor
@RequestMapping("/learning")
public class LearningController {

    private final UserLearningSessionService userLearningSessionService;

    @GetMapping
    public ResponseEntity<String> receiveHeartbeat(@RequestParam("username") String username) {
//        userLearningSessionService.updateUserActivity(username, (HttpServletResponse) httpServletResponse);  // 更新用户活跃时间
        return ResponseEntity.ok("Heartbeat received for user: " + username);
    }

    @GetMapping("/info")
    public Result getStuInfo(){
        List<UserLearningSession> list = userLearningSessionService.selectAll();
        return Result.ok(Status.SUCCESS,list);
    }
}
